﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>克隆表格</title>
    <script type="text/javascript">
        i = 1;        
        function add(){
            ++i;
            var newTr = r1.cloneNode(true);
            newTr.id="r" + i;
            newTr.name="r" + i;
            r1.parentNode.insertAdjacentElement("beforeend",newTr);
        }
    </script>
</head>
<body>
<input type=button value=克隆表格 name=mytxt onclick=add()>
<table border=1>
    <tr id=r1 name=r1>
        <td>第一列</td><td>第二列</td>
    </tr>
</table>
</body>
</html>